﻿$(function () {
    $("#inServiceStatus").ligerComboBox({
        width: 100,
        cancelable: false,
        valueFieldID: 'hdnInServiceStatus',
        value: -1
    });

    $("#areaId").ligerComboBox({
        width: 100,
        cancelable: false,
        url: "/Personnel/PersonnelList/GetDepartmentList?ram" + Math.random(),
        parms: { isAll: 1 },
        valueField: "value",
        textField: "text",
        valueFieldID: 'hdnAreaId',
        value: -1,
        onSuccess: function (data) { }
    });

    $('#btnSearch').click(function () {
        search();
    });

    search();
});

//加载列表
function initTable(queryData, pageNumber) {
    $("#maingrid").ligerGrid({
        height: '100%',
        url: '/Personnel/PersonnelList/Search?ram=' + Math.random(),
        parms: queryData,
        page: pageNumber,
        pageSize: 30,
        rownumbers: true,
        heightDiff: -5,
        columns: [
        { display: '工号', name: 'UserId' },
        { display: '姓名', name: 'Name' },
        { display: '性别', name: 'Sex' },
        { display: '民族', name: 'Nation' },
        {
            display: '操作', name: '', minWidth: 100, render: function (row) {
                return '<a href="javascript:void(0);"  class="a-edit" onclick="edit(' + row.ID + ',' + row.Status + ')">查看</a>';
            }
        }]
    });
    GridNoData($("#maingrid"));
}

//搜索
function search(pageNumber) {
    var queryData = {
        inServiceStatus: $("#hdnInServiceStatus").val(),
        name: $("#txtName").val(),
        areaId: $("#hdnAreaId").val()
    }
    initTable(queryData, pageNumber);
}

//查看
function edit(id, status) {
    window.location.href = "/Personnel/EditPersonnel/Index?id=" + id + "&pageType=1&status=" + status;
}